//
//  LWSearchView.swift
//  MicroBlog
//
//  Created by 孙程 on 2017/7/15.
//  Copyright © 2017年 孙程. All rights reserved.
//

import UIKit

class LWSearchView: UIView {

    @IBOutlet weak var searchRightConstraint: NSLayoutConstraint!
    
    
    @IBOutlet weak var searchButton: UIButton!
    
    @IBOutlet weak var searchTextFild: UITextField!
    
    
    @IBAction func eadteBeginAction(_ sender: Any) {
        
        searchRightConstraint.constant = searchButton.width
        //添加动画效果
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
        
        }
    
    //搜索按钮的点击事件
    @IBAction func searchBtnAction(_ sender: Any) {
        //辞去第一响应者
        searchButton .resignFirstResponder()
        searchRightConstraint.constant = 0
        
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
        
    }
    
    //使用类方法创建Xib对象
    class func searchView()->LWSearchView{
        return UINib(nibName: "LWSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! LWSearchView
    }
    
}
